package com.kt.bit.bidw.bizmeta.controller;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kt.bit.bidw.bizmeta.service.BizMetaInfoService;
import com.kt.bit.bidw.common.authority.SessionInfo;
import com.kt.bit.bidw.common.authority.SessionInfoSupport;
import com.kt.bit.bidw.meta.util.KTHashMap;
import com.kt.framework.controller.impl.KTControllerImpl;
import com.kt.framework.exception.BizException;

/**
 * 비즈니스메타 정보 관리 Contol Class
 * <br/><b>History</b><br/>
 * <pre>
 * 2012. 5. 4. 최초작성
 * </pre>
 * @author cjsxowls
 * @version 1.0
 */
@Controller(value="bizMetaInfoController")
@RequestMapping(value="/bizMetaInfo.json")
public class BizMetaInfoController extends KTControllerImpl {
	 
	private static final Log LOG = LogFactory.getLog(BizMetaInfoController.class); 
	
	@Autowired
	private BizMetaInfoService bizMetaInfoService;
	
	/**
	 * 비즈니스메타 조회 <br>
	 * @param param 조회조건
	 * @return List 비즈니스메타 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizObjBasList")
	@ResponseBody
	public List<Map<String, Object>> bizObjBasList (
			final HttpServletRequest request,
			@RequestBody final KTHashMap<String, Object> params) throws IOException { 
		if (LOG.isDebugEnabled()) {
			LOG.debug("BizMetaInfoController.bizObjBasList Method.");
		}
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizObjBasList(params);
		}
	}
	
	/**
	 * 비즈니스메타 요청 조회 <br>
	 * @param param 조회조건
	 * @return List 비즈니스메타 요청 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizObjReqList")
	@ResponseBody
	public List<Map<String, Object>> bizObjReqList(
			final HttpServletRequest request,
			@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizObjReqList(params);
		}
	}
	
	/**
	 * BI정보검색 검색Key 조회 <br>
	 * @param param 조회조건
	 * @return List 객체유형별 검샥Key 리스트
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=atribSearchKeyListByTypeId")
	@ResponseBody
    public List<Map<String, Object>> atribSearchKeyListByTypeId (
    		final HttpServletRequest request,
            @RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.atribSearchKeyListByTypeId(params);
		}
    }
	
	/**
	 * BI정보검색 조회 <br>
	 * @param param 조회조건
	 * @return List BI정보검색 객체유형별 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizPotalSearchList")
	@ResponseBody
    public Map<String, Object> bizPotalSearchList (
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizPotalSearchList(params);
		}
    }
	
	/**
	 * BI정보검색 기본 조회 <br>
	 * @param param 조회조건
	 * @return List BI정보검색 객체유형별 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizPotalSearchDefaultList")
	@ResponseBody
    public Map<String, Object> bizPotalSearchDefaultList (
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizPotalSearchDefaultList(params);
		}
    }
	
	/**
	 * 관점객체 관점멤버  조회 <br>
	 * @param param 조회조건
	 * @return List 관점객체 관점멤버 대상 스키마테이블 조회
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizViewObjData")
	@ResponseBody
    public Map<String, Object> bizViewObjData (
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizViewObjData(params);
		}
    }
	
	/**
	 * 관점객체 관점멤버 어트리뷰트대상 조회 <br>
	 * @param param 조회조건
	 * @return List 관점객체 관점멤버 어트리뷰트 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=objViewMemberList")
	@ResponseBody
    public List<Map<String, Object>> objViewMemberList(
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.objViewMemberList(params);
		}
    }
	
	/**
	 * 조직도 조회 <br>
	 * @param param 조회조건
	 * @return List 조직도 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizOrgList")
	@ResponseBody
    public List<Map<String, Object>> bizOrgList(
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizOrgList(params);
		}
    }
	
	/**
	 * 비즈니스메타 요청자 조회 <br>
	 * @param param 조회조건
	 * @return List 비즈니스메타 요청자 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizRqtUserList")
	@ResponseBody
    public List<Map<String, Object>> bizRqtUserList(
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizRqtUserList(params);
		}
    }
	
	/**
	 * 비즈니스메타 관리자 조회 <br>
	 * @param param 조회조건
	 * @return List 비즈니스메타 관리자 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizOwnerList")
	@ResponseBody
    public List<Map<String, Object>> bizOwnerList(
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizOwnerList(params);
		}
    }
	
	/**
	 * 정형리포트 실행을 위한 리스트 조회 <br>
	 * @param param 조회조건
	 * @return List 프로젝트 리스트 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizPotalProjectRptList")
	@ResponseBody
    public List<Map<String, Object>> bizPotalProjectRptList(
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizPotalProjectRptList(params);
		}
    }
	
	/**
	 * Biz Meta Mstr Mapping 리스트 조회 <br>
	 * @param param 조회조건
	 * @return List<Map<String, Object>>
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizMstrMappingList")
	@ResponseBody
    public List<Map<String, Object>> bizMstrMappingList(
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizMstrMappingList(params);
		}
    }
	
	/**
	 * Biz Meta Mstr Mapping 리스트 조회 <br>
	 * @param param 조회조건
	 * @return List<Map<String, Object>>
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizPotalSearchTreeList")
	@ResponseBody
    public List<Map<String, Object>> bizPotalSearchTreeList(
    		final HttpServletRequest request,
    		@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return bizMetaInfoService.bizPotalSearchTreeList(params);
		}
    }
}